home *** CD-ROM | disk | FTP | other *** search
/ Creative Computers / Creative Computers CD-ROM, Volume 1 (Legendary Design Technologies, Inc.)(1994).iso / shareware / games / uchess / src / gnuchess.h < prev    next >
C/C++ Source or Header  |  1994-11-17  |  25KB  |  880 lines

  1. /*#define LONGINTS 1*/
  2. #define NODITHER 1
  3. #define INTSIZE short
  4. /*#define LONGINTS2 1*/
  5. #ifdef LONGINTS
  6. #define INTSIZE2 long
  7. #else
  8. #define INTSIZE2 short
  9. #endif
  10.  
  11.  
  12. #ifdef _M68040
  13. #define VERSTRING "UChess v2.83L(040)"
  14. #define AVSTR "$VER: UChess 2.83L [040] (21.04.94)"
  15. #else
  16. #ifndef TINYCHESS
  17. #define VERSTRING "UChess v2.83(020)"
  18. #define AVSTR "$VER: UChess 2.83 [020] (21.04.94)"
  19. #else
  20. #define VERSTRING "UChess v2.83T(020)"
  21. #define AVSTR "$VER: UChess 2.83T [020] (21.04.94)"
  22. #endif
  23. #endif
  24.  
  25.  
  26. #define ARGSZ long
  27.  
  28. #define REG register
  29.  
  30. /* 
  31.    To fix it as a tool for pgm use, modify the routine
  32.    InputCommand() in dspcom.c and OutputMove() in nondsp.c 
  33.    modify main.c to setup screen, etc,
  34.    modify inline statement below,
  35.    Modify SelectLevel in nondsp.c so that it does not use scanf
  36.    in dspcom.c, ElapsedTime function is where you cut short
  37.    any thinking on human players time.  Around the FIONREAD
  38.    area, you need a loop for looking for the intuition events
  39.    and stop the thinking short if that happens
  40.  
  41.    Modify PromptForMove in nondsp.c, actaully may not be needed at all
  42.  
  43.    */
  44.  
  45. /*
  46.  * gnuchess.h - Header file for GNU CHESS
  47.  *
  48.  * Copyright (c) 1988,1989,1990 John Stanback
  49.  * Copyright (c) 1992 Free Software Foundation
  50.  *
  51.  * This file is part of GNU CHESS.
  52.  *
  53.  * GNU Chess is free software; you can redistribute it and/or modify
  54.  * it under the terms of the GNU General Public License as published by
  55.  * the Free Software Foundation; either version 2, or (at your option)
  56.  * any later version.
  57.  *
  58.  * GNU Chess is distributed in the hope that it will be useful,
  59.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  60.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  61.  * GNU General Public License for more details.
  62.  *
  63.  * You should have received a copy of the GNU General Public License
  64.  * along with GNU Chess; see the file COPYING.  If not, write to
  65.  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  66.  */
  67.  
  68. /*
  69.  
  70.  On an Amiga 4000, Gnuchess 4.0 gets from  80,000(short), 100,000 (long)
  71.  nodes/sec on MoveList, and 3000(s)-3700(l) Nodes/sec on Eval Speed 
  72.  
  73.  On a SunStation (netcom), Gnuchess 4.0 gets from 100,000 to 133,300 nodes/sec on
  74.  MoveList, and 3700 Nodes/sec on Eval Speed 
  75.  
  76. */
  77.  
  78.  
  79. #if !defined(__STDC__) || !defined(MSDOS)
  80. #define const
  81. #endif
  82.  
  83. #ifndef __GNUC__
  84. #define inline __inline
  85. #endif
  86.  
  87. #include <stdio.h>
  88.  
  89. #ifdef AMIGA
  90. #undef printf
  91. #define printf NULLY
  92. #undef stdin
  93. #undef stdout
  94. #undef stderr
  95. #define stdin NULLYIN
  96. #define stdout NULLYOUT
  97. #define stderr NULLYERR
  98. #undef scanf
  99. #define scanf NULLYSCANF
  100. #endif
  101.  
  102. #define SEEK_SET 0
  103. #define SEEK_END 2
  104. #ifdef DEBUG
  105. void
  106. ShowDBLine (char *, INTSIZE int, INTSIZE int,
  107.         INTSIZE int, INTSIZE int, INTSIZE int,
  108.         INTSIZE unsigned int *);
  109.      extern FILE *debugfd;
  110.      extern INTSIZE int debuglevel;
  111.  
  112. #endif /* DEBUG */
  113.  
  114. #include <ctype.h>
  115.  
  116. #ifdef AMIGA
  117. #include <exec/types.h>
  118. #include <dos/dos.h>
  119. #endif
  120.  
  121.  
  122. extern long int GenCnt;
  123.  
  124. extern int GlobalTgtDepth;
  125. extern int TCadd;
  126. extern int mycnt3;
  127. extern int globalmessage_valid;
  128. extern struct IntuiMessage __aligned globalmessage;
  129. extern char __far HintString[80];
  130. extern char __far MateString[40];
  131. extern int AmigaStarted;
  132. extern int Mate;
  133. extern int DrawnGame;
  134.  
  135. void
  136.  TestSpeed (void (*f) (INTSIZE int side, INTSIZE int ply), unsigned j);
  137. void
  138.  TestPSpeed (INTSIZE int (*f) (INTSIZE int side), unsigned j);
  139.  
  140. void GetEditText(char *,int *);
  141. void CloseAmigaEditWindow(void);
  142. int OpenAmigaEditWindow(void);
  143.  
  144. unsigned int urand (void);
  145. void gsrand (unsigned int seed);
  146.  
  147. #ifdef AMIGA
  148. void __regargs MoveMem(void *,void *,ULONG);
  149. void __regargs MoveMem128(void *,void *);
  150. void __regargs ClearMem(void *,ULONG);
  151. #endif
  152. int myfgets(char *,int ,BPTR);
  153. int DoResign(void);
  154. void EnableMoveNow(void);
  155. void DisableMoveNow(void);
  156. void UpdateClocks (void);
  157. int LoadFullBitMap(void);
  158. void DoLegalMove(char *);
  159. void DisplayComputerMove(char *);
  160. void HandleEvent(APTR);
  161. void DoAbout(void);
  162. void LoadAGame(void);
  163. void SaveAGame(void);
  164. void ListAGame(void);
  165. void DoQuit(void);
  166. void Go2D(void);
  167. void Go3D(void);
  168. void DoReverse(void);
  169. void DoSwap(void);
  170. void DoAutoPlay(void);
  171. void MoveNow(void);
  172. void TakeBack(void);
  173. void DoThinking(void);
  174. void DoShwThnk(void);
  175. void DoSuper(void);
  176. void DoBookToggle(void);
  177. void DoHint(void);
  178. void DoTest(void);
  179. void SetTime(void);
  180. int GetFileName(char *);
  181.  
  182. void DisplayError(char *);
  183. void GetOperatorEntry(char *);
  184. void AmigaShutDown(void);
  185. void AnimateAmigaMove(char *,char);
  186. void GetTimeString(char *);
  187. void GiveHint(void);
  188. void EditBoard(void);
  189. void help(void);
  190. void ChangeAlphaWindow(void);
  191. void ChangeBetaWindow(void);
  192. void ChangeSearchDepth(void);
  193. void ChangeHashDepth(void);
  194. void SetContempt(void);
  195. void ChangeXwindow(void);
  196. void ShowPostnValues(void);
  197. void DoDebug(void);
  198. void DoTable(INTSIZE *);
  199.  
  200. void GetGame(void);
  201. void SaveGame(void);
  202. void DrawAmigaBoard(void);
  203. void skip(void);
  204. void skipb(void);
  205. void EnPassant (INTSIZE int xside, INTSIZE int f, INTSIZE int t, INTSIZE int iop);
  206.  
  207. void ataks(INTSIZE int, INTSIZE int *);
  208. void Initialize_dist(void);
  209. void InitConst(char *);
  210. int SetAmigaDepth(void);
  211.  
  212.  
  213. #ifdef MSDOS
  214. #include <stdlib.h>
  215. #include <string.h>
  216. #include <time.h>
  217. #define RWA_ACC "r+b"
  218. #define WA_ACC "w+b"
  219. #else
  220. #define RWA_ACC "r+"
  221. #define WA_ACC "w+"
  222. /*
  223. #include <sys/param.h>
  224. #include <sys/types.h>
  225. #include <sys/times.h>
  226. */
  227. #include <stdlib.h>
  228. #include <string.h>
  229. #include <time.h>
  230.  
  231. extern int FirstTime;
  232.  
  233. #endif /* MSDOS */
  234. #ifdef NONDSP
  235. #ifdef AMIGA
  236. #define printz NULLFUNC
  237. #define scanz NULLFUNC2
  238. #else
  239. #define printz printf
  240. #define scanz scanf
  241. #endif
  242. #else
  243. #include <curses.h>
  244. #define scanz fflush(stdout),scanw
  245. #define printz printw
  246. #endif
  247.  
  248. #if defined(__STDC__) || defined(MSDOS)
  249. /* <stdio.h> */
  250.      extern int fclose (FILE *);
  251. #ifndef __ultrix /* work around bug in c89 compiler --t.mann */
  252. #endif /*__ultrix*/
  253.  
  254. /* <stdlib.h> */
  255.  
  256. /* <time.h> */
  257.  
  258. /* <string.h> */
  259. #endif
  260.  
  261.  
  262. /* Piece values */
  263. #define valueP 100
  264. #define valueN 350
  265. #define valueB 355
  266. #define valueR 550
  267. #define valueQ 1100
  268. #define valueK 1200
  269. /* masks into upper 8 bits of ataks array */
  270. #define ctlP 0x4000
  271. #define ctlN 0x2800
  272. #define ctlB 0x1800
  273. #define ctlR 0x0400
  274. #define ctlQ 0x0200
  275. #define ctlK 0x0100
  276. #define ctlBQ 0x1200
  277. #define ctlBN 0x0800
  278. #define ctlRQ 0x0600
  279. #define ctlNN 0x2000
  280. /* attack functions */
  281. #define Patak(c, u) (atak[c][u] > ctlP)
  282. #define Anyatak(c, u) (atak[c][u] > 0)
  283. /* distance function */
  284. #define taxicab(a,b) taxidata[a][b]
  285. /* hashtable flags */
  286. #define truescore 0x0001
  287. #define lowerbound 0x0002
  288. #define upperbound 0x0004
  289. #define kingcastle 0x0008
  290. #define queencastle 0x0010
  291. #define evalflag 0x0020 /* from PL 61 */
  292. /* king positions */
  293. #define wking PieceList[white][0]
  294. #define bking PieceList[black][0]
  295. #define EnemyKing PieceList[c2][0]
  296. /* constants */
  297. /* castle moves */
  298. #define BLACKCASTLE    0x3C3E
  299. #define WHITECASTLE    0x0406
  300. #define LONGBLACKCASTLE    0x3C3A
  301. #define LONGWHITECASTLE    0x0402
  302. /* truth values */
  303. #define false 0
  304. #define true 1
  305. /* colors */
  306. #define white 0
  307. #define black 1
  308. #define neutral 2
  309. /* piece code defines */
  310. #define no_piece 0
  311. #define pawn 1
  312. #define knight 2
  313. #define bishop 3
  314. #define rook 4
  315. #define queen 5
  316. #define king 6
  317. #define bpawn 7
  318. /* node flags */
  319. #define pmask 0x0007
  320. #define promote 0x0008
  321. #define cstlmask 0x0010
  322. #define epmask 0x0020
  323. #define exact 0x0040
  324. #define pwnthrt 0x0080
  325. #define check 0x0100
  326. #define capture 0x0200
  327. #define draw 0x0400
  328. #define book 0x1000
  329. /* move symbols */
  330. #define pxx (CP[2])
  331. #define qxx (CP[1])
  332. #define rxx (CP[4])
  333. #define cxx (CP[3])
  334. /* for everything that can't use the above */
  335. #define Qxx " pnbrqk"
  336. #define Pxx " PNBRQK"
  337. #define Cxx "abcdefgh"
  338. #define Rxx "12345678"
  339. /***************************************************************************/
  340. /***************** Table limits ********************************************/
  341. /*
  342.  * ttblsz must be a power of 2. Setting ttblsz 0 removes the transposition
  343.  * tables.
  344.  */
  345. #ifdef MSDOS
  346. #define vttblsz (1 << 11)
  347. #else
  348. #ifdef _M68040
  349. #define vttblsz (200001) // was 1 << 17 in 2.35
  350. #else
  351. #ifndef TINYCHESS
  352. #define vttblsz (1 << 16)
  353. #else
  354. #define vttblsz (1 << 14)
  355. #endif
  356. #endif
  357. #define huge
  358. #endif /* MSODS */
  359.  
  360. #define ttblsz vttblsz
  361. #define TREE 1500        /* max